{* $Id$ *}
{include_core file="admin/lib/header.html" title="焦点图展示"}
{if empty($search_filter) && empty($focus_list) && $status != 0 && 1 != 1}
  <div class="search-none search-none-bg">
    <p>还没有焦点图发布，点击<a href="{AnUrl('focus/admin/add')}" class="search-none-add">添加焦点图</a></p>
  </div>
{else}
  <div class="page-header border-bottom clearfix">
    <h2 class="left">焦点图管理<span>在这里对焦点图进行管理</span></h2>
    <a href="{AnUrl('focus/admin/add')}" class="btn btn-success btn-sm right"><i class="icon-add"></i>添加焦点图</a>
  </div>
  <div class="search-level1 clearfix">
    <form action="focus/admin" method="get">
      <input type="hidden" name="is_advenced" value="0">
      <input type="hidden" name="status" value="{$status}">
      <input {if $is_advenced == 1}style="display:none;"{/if} type="text" class="left" name="search_filter[title]" value="{$search_filter.title}">
      <button {if $is_advenced == 1}style="display:none;"{/if} type="submit" class="btn btn-success btn-sm left">搜索</button>
      <a href="javascript:void(0);" class="close js_advanced {if $is_advenced == 1}js_isOpen open{/if}">高级搜索<em></em></a>
    </form>
  </div>
  <div class="search-form js_advancedForm" {if $is_advenced == 0}style="display:none;"{/if}>
    <form action="focus/admin" method="get" class="js_focusSearchForm">
      <input type="hidden" name="is_advenced" value="1">
      <input type="hidden" name="status" value="{$status}">
      <p>
        <label for="" class="search-f-label">推送位置：</label>
        {$position_list = focus_config::$focus_position_list}
        <select class="search-f-slt1" name="search_filter[res_name]">
          {foreach $position_list as $k=>$v}
          <option value="{$k}" {if $search_filter.res_name==$k}selected{/if}>{$v}</option>
          {/foreach}
        </select>
      </p>
      <p>
        <label for="" class="search-f-label">标题：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[title]" value="{$search_filter.title}">
      </p>
      <p>
      <label for="" class="search-f-label">添加时间：</label>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[start_date]" value="{$search_filter.start_date}" id="startDate">
        <span class="search-f-line"></span>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[end_date]" value="{$search_filter.end_date}" id="stopDate">
      </p>
      <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
    </form>
  </div>
  <!--start:列表-->
  <table class="list-table">
    <caption>按状态：
      <a href='{AnUrl("focus/admin?status=1")}' {if $status == 1} class="label label-primary" {else} class="label label-default" {/if}>正常</a>
      <a href='{AnUrl("focus/admin?status=0")}' {if $status == 0} class="label label-primary" {else} class="label label-default" {/if}>已删除</a>
    </caption>
    <thead><tr>
      {if $status == 1}
      <th style="width:20px;"><input type="checkbox" class="selectAll"></th>
      {/if}
      <th style="width:20px;">排序</th>
      <th style="min-width:200px;">标题</th>
      <th style="width:60px;">封面</th>
      <th style="min-width:60px;">位置</th>
      {*<th style="min-width:60px;">所属子版块</th>*}
      <th style="width:130px;">添加时间</th>
      <th style="width:180px;">操作</th>
    </tr></thead>
    <tbody>
      {foreach $focus_list as $k=>$v}
        <tr id="dataList{$v.id}" {if $k%2 == 1} class="bg-gray"{/if} data-id="{$v.id}">
          {if $status == 1}
          <td><input type="checkbox" class="listSelect"></td>
          {/if}
          <td>{$v.view_order}</td>
          <td>{$v.title}</td>
          <td>
            {if $v.cover}
              <img width="70" src="{_image($v.cover)}">
            {/if}
          </td>
          <td>{focus_config::$focus_position_list[$v.res_name]['title']}</td>
          {*<td>{_uri('focus_columns',$v.columns_id,'title')}</td>*}
          <td>{time_format($v.add_time)}</td>
          <td>
            {if $status == 1}
              <span style="display:none;" id="js_text_{$v.id}">{$v.link}</span>
              <a href="javascipt:void(0);" class="btn btn-success btn-xs js_copyList" id="js_copy_{$v.id}" data-clipboard-target="js_text_{$v.id}">复制链接</a>
              <a href="{AnUrl("focus/admin/edit?id={$v.id}")}" class="btn btn-info btn-xs"><i class="icon-edit icon-white"></i>编辑</a>
              <a href="{AnUrl("focus/admin/delete?id={$v.id}")}" class="btn btn-danger btn-xs deleteOne"><i class="icon-trash icon-white"></i>删除</a>
            {elseif $status == 0}
              <a href="{AnUrl("focus/admin/change_status?status=1")}" class="btn btn-success btn-xs changeStatus"><i class="icon-trash icon-white"></i>恢复</a>
            {/if}
          </td>
        </tr>
      {foreachelse}
          <tr><td class="txtleft" colspan="6">暂无数据</td></tr>
      {/foreach}
    </tbody>
    {if $status == 1}
    <tfoot><tr><td><input type="checkbox" class="selectAll"></td><td colspan="6"><a href="{AnUrl("focus/admin/delete")}" class="btn btn-danger btn-xs deleteAll">批量删除</a></td></tr></tfoot>
    {/if}
  </table>
  {include_core file="admin/lib/pager.html"}
{/if}
<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
<script>
var resName = 'focus';
var jsCategoryId = "{$search_filter.category_id}";
$('.js_categoryId').load(siteUrl+'/category/load_category_option?res_name='+resName,function(){
  $('.js_categoryId').find('option').each(function(){
    if ($(this).attr('value') == jsCategoryId) {
      $(this).attr('selected','selected');
    }
  });
});
$(function(){
  // 高级搜索
  $('.js_advanced').click(function(e){
    e.preventDefault();
    var thisObj = $(this);
    var outBox  = thisObj.closest('form');
    if (thisObj.hasClass('js_isOpen')) {
      thisObj.removeClass('js_isOpen open');
      outBox.find('input').show();
      outBox.find('button').show();
      $('.js_advancedForm').hide();
    } else {
      thisObj.addClass('js_isOpen open');
      outBox.find('input').hide();
      outBox.find('button').hide();
      $('.js_advancedForm').show();
    }
  });
  
  // 高级搜索时间验证
  $('.js_searchBtn').click(function(e){
    e.preventDefault();
    var thisObj   = $(this);
    var startDate = $.trim($('#startDate').val());
    var stopDate  = $.trim($('#stopDate').val());
    if (startDate > stopDate) {
      showMsg('结束时间应大于等于开始时间');
      return;
    }
    thisObj.closest('form').submit();
  });

  // 页面复制
  var clip = new ZeroClipboard( $('.js_copyList'), {
    moviePath: "../../../../js/zclip/ZeroClipboard.swf"
  });
  clip.on( 'complete', function(client, args) {
    showMsg("复制成功，复制内容为："+ args.text, 1);
  });
  
  // 查看预览效果
  $('.js_previewBtn').each(function(i){
    $(this).click(function(e){
      e.preventDefault();
      var thisObj = $(this);
      var resName = 'focus';
      var resId = thisObj.closest('tr').attr('data-id');
      
      showPreviewDialog(resName, resId);
    });
  });
});
</script>
{include_core file="admin/lib/footer.html"}